local HQ = GROUP
	:FindByName("HQ")

local CommandCenter = COMMANDCENTER
	:New( HQ, "格里芬指挥部")

local Mission = MISSION
	:New( CommandCenter, "格里芬指挥中心", "High", "近距空中支援与对地打击", coalition.side.BLUE)

local RecceSet = SET_GROUP
	:New()
	:FilterPrefixes("JTAC")
	:FilterStart()

local DetectionAreas = DETECTION_AREAS
	:New( RecceSet, 3000 )

local AttackSet = SET_GROUP
	:New()
	:FilterCoalitions( "blue" )
	:FilterStart()

TaskDispatcher = TASK_A2G_DISPATCHER
	:New( Mission, AttackSet, DetectionAreas)

local Scoring = SCORING:New( "A2A Scoring" )
local a2amission = MISSION
	:New( CommandCenter, "格里芬空中拦截指挥", "High", "拦截敌机以及夺取空优", coalition.side.BLUE)
	:AddScoring( Scoring )
EWRSet = SET_GROUP:New():FilterPrefixes("EWR"):FilterCoalitions("blue"):FilterStart()
EWRDetection = DETECTION_AREAS:New( EWRSet, 60000 )
EWRDetection:SetFriendliesRange( 80000 )
EWRDetection:SetRefreshTimeInterval(30)
AATask = TASK_A2A_DISPATCHER:New( a2amission, AttackSet, EWRDetection)
AATask:SetRefreshTimeInterval( 10 )

function TaskDispatcher:OnAftterSuccess( From, Event, To, Task)
	trigger.action.outText("任务完成", 10, 0, true)
end

function AATask:OnAfterAssign( From, Event, To, Task, TaskUnit, PlayerName )
	Task:SetScoreOnProgress( PlayerName, 1, TaskUnit )
	Task:SetScoreOnSuccess( PlayerName, 2, TaskUnit )
	Task:SetScoreOnFail( PlayerName, -100, TaskUnit )
end

function AATask:OnAftterSuccess( From, Event, To, Task)
	Task:Success()
	trigger.action.outText("任务完成", 10, 0, true)
end

-- MissileTrainer = MISSILETRAINER
-- 	:New( 200, "导弹将在命中你之前摧毁。")
-- 	:InitMessagesOnOff(true)
-- 	:InitAlertsToAll(true)
-- 	:InitAlertsHitsOnOff(true)
-- 	:InitAlertsLaunchesOnOff(false)
-- 	:InitBearingOnOff(true)
-- 	:InitRangeOnOff(true)
-- 	:InitTrackingOnOff(true)
-- 	:InitTrackingToAll(true)
-- 	:InitMenusOnOff(false)

-- MissileTrainer:InitAlertsToAll(true)